package com.tom.service.impl;

import com.tom.dao.PersonDao;
import com.tom.domain.Person;
import com.tom.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {

    @Autowired
    private PersonDao personDao;

    public boolean save(Person person) {
        if (person.getId() != null) {
            return personDao.update(person);
        } else {
            return personDao.save(person);
        }
    }

    public Person get(Integer id) {
        return personDao.get(id);
    }

    public boolean remove(Integer id) {
        return personDao.remove(id);
    }

    public List<Person> list() {
        return personDao.list();
    }
}
